<template>
	<view class="coupon-list">
		<view class="m-t-20">
			<!-- <view :class="'coupon-item flex ' + (btnType == 1 || btnType == 2 ? 'gray': '')"> -->
			<view class="coupon-item flex gray">
				<view class="price white flex-col col-center">
					<view class="xl">
						<price-format :first-size="60" :second-size="50" :subscript-size="34" :price="list.money"
							:weight="500" />
					</view>
					<view class="sm text-center">{{list.condition_type_desc}}</view>
				</view>
				<view class="info m-l-20">
					<view class="lg m-b-20">{{list.name}}</view>
					<view class="xs lighter m-b-20">{{list.use_time_desc}}</view>
					<view class="xs lighter">{{list.use_scene_desc}}</view>
				</view>
				<!-- <image v-if="list.is_get" class="receive" src="/bundle/static/image/coupon_bg.png"></image> -->
			</view>
			<!-- <view style="padding: 14rpx 20rpx" class="bg-white" v-if="item.use_goods_desc" @tap="onShowTips(index)">
				<view class="flex row-between">
					<view class="xs">使用说明</view>
					<u-icon :class="showTips[index] ? 'rotate' : ''" name="arrow-down" />
				</view>
				<view v-show="showTips[index]" class="m-t-10 xs">{{item.use_goods_desc}}</view>
			</view> -->
		</view>
		<view class="submit-s" @tap="getCouponCode">立即领取</view>
	</view>
</template>


<script>
	import {
		getCouponCodeDetail,getCouponCode
	} from '@/api/activity';
	import {
		strToParams,
		arraySlice,
		getRect,
		getcu
	} from '@/utils/tools'
	export default {
		data() {
			return {
				list:[],
				codeid:'',
				codeuserid:'' 
			};
		},
		onLoad: function() {
			const options = this.$Route.query;
			console.log("3214",options)
			this.codeid = options.coupon_id;
			this.codeuserid = options.give_user_id;
			if (options && options.scene) {
				const scene = strToParams(decodeURIComponent(options.scene));//扫码要scene
				console.log('scene',scene)
				this.codeid = scene.coupon_id;
				this.codeuserid = scene.give_user_id;
			}
			this.getCouponCodeDetail()
		},
		methods: {
			async getCouponCode(){
				const {
					data,
					code,
					msg
				} = await getCouponCode({
					coupon_id:this.codeid,
					give_user_id:this.codeuserid
				})
				if (code == 1) {
					this.$toast({
						title: msg
					});
					setTimeout(()=>{
						uni.navigateTo({
							url:'/bundle_b/pages/user_coupon/user_coupon'
						})
					},1300)
				}
			},
			getCouponCodeDetail() {
				getCouponCodeDetail({
					// coupon_id:4,
					// give_user_id:446
					coupon_id:this.codeid,
					give_user_id:this.codeuserid
				}).then(res => {
					if (res.code == 1) {
					this.list = res.data
					}
				});
			}
		}
	};
</script>
<style lang="scss">
	.submit-s{
		text-align: center;
		color: #ffffff;
		padding: 20rpx;
		font-size: 30rpx;
		border-radius: 50rpx;
		margin: 70rpx 6rpx ;
		background-color: #fc4036;
		// margin-top: 800rpx;
		width: 690rpx;
		position: fixed;
		bottom: 0;
	}
	.coupon-list {
		padding: 0 24rpx;
		overflow: hidden;
		.coupon-item {
			position: relative;
			height: 200rpx;
			background-image: url(/bundle/static/image/coupon_bg.png);
			background-size: 100% 100%;

			&.gray {
				// background-image: url(../../static/images/coupon_bg_grey.png);

				.btn {
					&.plain {
						color: #CCCCCC;
					}
				}
			}

			.price {
				width: 200rpx;
			}

			.btn {
				line-height: 52rpx;
				height: 52rpx;
				position: absolute;
				right: 20rpx;
				bottom: 20rpx;
				width: 120rpx;
				text-align: center;
				padding: 0;

				&.plain {
					background-color: #fff;
					color: $-color-primary;
					border: 1px solid currentColor;
				}
			}

			.receive {
				position: absolute;
				right: 30rpx;
				top: 0rpx;
				width: 99rpx;
				height: 77rpx;
			}
		}

		.icon {
			transition: all 0.4s;
		}

		.rotate {
			transform: rotateZ(-180deg);
		}
	}
</style>
